package com.tandashi.springbootstudy01.service.strategy.service;

import com.tandashi.springbootstudy01.service.strategy.dto.Order;
import com.tandashi.springbootstudy01.service.strategy.factory.OrderProcessStrategyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderProcessService {

    @Autowired
    private OrderProcessStrategyFactory strategyFactory;

    public void processOrder(Order order){
        //选择处理策略
        OrderProcessStrategy strategy = strategyFactory.getStrategy(order.getType());

        //执行处理流程
        strategy.process(order);
    }
}
